﻿//ajax弹出层
$(document).ready(function () {
    $.getScript('../../Scripts/Js/jquery.event.drag.min.js');
    var classname = 'window';
    var contentname = 'window-content';
    var address = 'Detail/';                            //请求页面地址
    var loadingimg = '../../Content/images/loading.gif';               //内容加载图片路径


    $('.det').click(function () {

        var teacherId = $(this).parents('tr').find('td').eq(0).text(); //找到编号Id
        address += teacherId; //  Detail/id
        classname += teacherId; //新窗口的class名 //windonwid
        contentname += teacherId; //window-contentid

        if ($("." + classname).length > 0) {//判断窗口是否已存在
            $("." + classname).remove();
        }
        var window = '<div class="' + classname + '"><div class="' + contentname + '"></div><div class="window-close"></div></div>';   //弹出层的结构
        //<div class="windowid">
        //  <div class="window-contentid">
        //  </div>
        //  <div class="window-close">
        //  </div>
        //</div>
        $('body').append(window);
        $("." + classname).addClass('window'); //添加统一样式类window


        $.ajax({              //调用jquery的ajax方法
            type: "GET",   //设置ajax方法提交数据的形式
            url: address,   //把数据提交到address
            dataType: "html",
            beforeSend: function () {
                $("." + contentname).html("<div class='loading'><img src='" + loadingimg + "' /></div>");
            },
            error: function () {
                $("." + contentname).css({ 'width': '200px', 'height': '80px' }).html("<p class='windown-error'>加载数据出错..</p>");
                $('.window-close').css('display', 'block');
            },
            success: function (html) {                  //提交成功后的回调，html 变量是 address 输出的内容。
                //           $('.hideZone').html();
                $('.window-close').css('display', 'block');
                $("." + contentname).html(html);

            }
        });
        address = 'Detail/'; //回复原来状态，等待下次请求
        classname = 'window';

        //关闭层
        $('.window-close').click(function () {
            $(this).parent().fadeOut('1000', function () { $(this).remove(); });
            //    $('.hideZone').remove();
        });

        //层移动效果
        $('.window').bind('drag', function (event) {
            $(this).css({
                top: Math.round(event.offsetY / 20) * 20,
                left: Math.round(event.offsetX / 20) * 20
            });
        });

        //点击层前置效果
        $('.window').click(function () {
            $(this).siblings('.window').css('z-index', '999901').end().css('z-index', '999910');
        });
    });

});
function IsDelete() {
    return confirm('你确定要删除此记录吗？');
}
